<template>
  <div id="tmpl">
    <div class="description">
      <div class="title">
        <h4>{{imageInfo.title}}</h4>
        <p>{{imageInfo.add_time | datefmt("YYYY-MM-DD HH-mm-ss")}} {{imageInfo.click}}次点击</p>
        <p class="line"></p>
      </div>
      <!-- 略缩图 -->
      <div class="mui-content">
        <ul class="mui-table-view mui-grid-view mui-grid-9">
          <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3" v-for="(item, index) in list">           
              <img class="preview-img" :src="item.src" height="100" @click="$preview.open(index, list)">
          </li>
        </ul>
      </div>
      <div v-html="imageInfo.content" class="infocontent"></div>
    </div>
    <!-- 评论组件 -->
    <div id="comment">
      <comment :id="id"></comment>
    </div>
  </div>
</template>

<script>
import common from "../kits/common.js"
import { Toast } from 'mint-ui'
import comment from "../subcom/comment.vue"
export default {
  components:{
    comment
  },
  data() {
    return {
      id:0,
      imageInfo: {},
      list: [
        /* {
          src: 'https://placekitten.com/600/400',
          w: 600,
          h: 400
        } */
        ]
    };
  },
  created(){
    this.id = this.$route.params.id;
    this.getimageInfo();
    this.getlist();
  },
  methods: {
    getimageInfo() {
      var url = common.domain + "/api/getimageInfo/" + this.id;
      this.$http.get(url).then(function (response) {
        var body = response.body;
        if (body.status != 0) {
          Toast(body.message);
          return
        }
        this.imageInfo = body.message[0];
      })
    },
    getlist(){
      var url = common.domain + "/api/getthumimages/" + this.id;
      this.$http.get(url).then(function (response) {
        var body = response.body;
        if (body.status != 0) {
          Toast(body.message);
          return
        }
        body.message.forEach(function(item){
          var img = new Image();
          img.src = item.src;
          item.h = img.height;
          item.w = img.width;
        })
        this.list = body.message;
      })
    }
  }
}
</script>
<style lang="css" scoped>
 /*图片详情样式*/
  .description{
	  padding: 10px;
  }
	.description  .title h4{
		color: #0094ff;
	}

  .description .title p{
	color:rgba(0,0,0,0.4);
	  margin-top: 10px;
  }

  .description .title .line{
	  height: 1px;
	  border-bottom: 1px solid rgba(0,0,0,0.4);
  }

  .mui-content,.mui-content ul{
	  background-color: #fff;
  }
  .mui-grid-view.mui-grid-9 .mui-table-view-cell{
	  border-right:0px;
	  border-bottom:0px;
  }
  .mui-grid-view.mui-grid-9{
	  border-top:0px;
	  border-left:0px;
  }


  .mui-content img{
    width: 100%;
  }

  .infocontent{
    font-size: 14px;
    color: #333;
    text-indent: 2em;
  }
</style>
